'use strict';
const db = uniCloud.database()
const collection = db.collection('houselist')
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const {pageNum, pageSize} = event
	
	// 分页处理：一页10条
	// 页码  开始位置  查多少条
	// 1 	0			10
	// 2	10			10
	const start = (pageNum - 1) * pageSize
	const {data} = await collection.skip(start).limit(pageSize).get()
	const {total} = await collection.count()
	
	//返回数据给客户端
	return {
		data,
		total
	}
};
